package com.fas.system.controller;

import com.fas.common.core.controller.BaseController;
import com.fas.common.core.domain.AjaxResult;
import com.fas.common.core.domain.entity.SysDept;
import com.fas.common.core.page.TableDataInfo;
import com.fas.common.utils.SecurityUtils;
import com.fas.system.domain.FasInspectionTask;
import com.fas.system.service.IFasInspectionTaskService;
import com.fas.system.service.ISysDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 巡检任务 Controller
 *
 * @author ruoyi
 */
@Api(tags = "巡检任务")
@RestController
@RequestMapping("/system/inspection/task")
public class FasInspectionTaskController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(FasInspectionTaskController.class);

    @Autowired
    private IFasInspectionTaskService fasInspectionTaskService;
    @Resource
    private ISysDeptService deptService;

    @ApiOperation(value = "巡检任务查询")
    @GetMapping("/list")
    public TableDataInfo findAll(FasInspectionTask fasInspectionTask,Integer pageNum, Integer pageSize){
        System.out.println("输入的参数："+ fasInspectionTask);
        Long deptId = SecurityUtils.getDeptId();
        SysDept sysDept = deptService.selectDeptById(deptId);
        String deptType = sysDept.getDeptType();
        if (deptType.equals("1") || deptType.equals("2")){
            if(fasInspectionTask.getDeptId() == null){
                fasInspectionTask.setDeptId(deptId.intValue());
            }
        }
        startPage();
        return getDataTable(fasInspectionTaskService.findAll(fasInspectionTask));
    }


    @ApiOperation(value = "小程序-巡检员-巡检路线-待开始路线-点击开始")
    @GetMapping("/minappLineStart/{id}")
    public AjaxResult minappLineStart(@PathVariable Long id){//任务id
        logger.debug("输入的参数："+ id);
        return toAjax(fasInspectionTaskService.minappLineStart(id));
    }



}
